import React from 'react'
import { inject, observer } from 'mobx-react';
import AddList from './AddList';
import { withRouter } from 'react-router-dom';
import { ActivityIndicator, Tools } from 'weaver-mobile'
import { transQueryParams } from '../../util/common';
const getLabel = Tools.getLabel;
@inject('wfworkflowAddStore')
@withRouter
@observer
class App extends React.Component {
  constructor(props) {
    super(props);
    const { wfworkflowAddStore, location = {} } = this.props;
    const queryParams = transQueryParams(location);
    let moduleid = queryParams.moduleid || "";
    if(location.params && parseInt(location.params.moduleid,0) > 0){
      moduleid = location.params.moduleid;
    }
    if (!queryParams.hasOwnProperty("retainCondition")) {
      let params = {
        "menuid": moduleid,
      }
      if(queryParams.hasOwnProperty("wfRange")){
        params.wfRange = queryParams.wfRange;
      }
      wfworkflowAddStore.getDatas(params);
    }
  }

  render() {
    const { isShowLoading } = this.props.wfworkflowAddStore;
    return (
      <div className="wf-add-wrap">
        <AddList wfworkflowAddStore={this.props.wfworkflowAddStore} />
        {isShowLoading && <ActivityIndicator
          toast
          text={getLabel(127955, "页面跳转中...")}
          animating={isShowLoading}
        />}
      </div>
    )
  }
}

export default App;